package cn.itcast.bos.web.action;


import javax.ws.rs.core.MediaType;

import org.apache.cxf.jaxrs.client.WebClient;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionContext;

import cn.itcast.bos.domain.page.PageBean;
import cn.itcast.bos.domain.take_delivery.Promotion;
/**
 * 宣传活动
 * @author 35368
 *
 */
@ParentPackage("json-default")
@Namespace("/")
@Controller
@Scope("prototype")
@SuppressWarnings("all")  //消除警告
public class PromotionAction extends BaseAction<Promotion>{
	//在BaseAction中已经对分页查询的参数:page  rows  进行了接收
	
	//http://localhost:9001/bos_management/services/promotionService/pageQuery?page=1&rows=4
	//宣传活动查询功能
	@Action(value="promotion_pageQuery",results={@Result(name="success",type="json")})
	public String pageQuery(){
		System.out.println("112");
		//基于webService    获取bos_management 的活动列表的数据信息
		PageBean<Promotion> pageBean = WebClient
				.create("http://localhost:9001/bos_management/services/promotionService/pageQuery?page="+page+"&rows="+rows)
				.accept(MediaType.APPLICATION_JSON).get(PageBean.class);
		
				
		//将查询的分页数据  结果  压入 值栈
		ActionContext.getContext().getValueStack().push(pageBean);
		return "success";
	}
}
